var Schema = mongoose.Schema;

var wishMongoSchema = new Schema({
    desc: String,
    minSupport: Number,
    maxDays: Number,
    images: {
        type: [       //图片
            {
                imageURL: String
            }], default: []
    },
    weight: {type: Number, default:1}
});
mongoose.model('wish', wishMongoSchema, 'wish');

var userWishMongoSchema = new Schema({
    //community: {type: Schema.Types.ObjectId, ref: 'community'},
    wish: {type: Schema.Types.ObjectId, sparse: true, ref: 'wish'},
    createdBy: String,   // wechat openid
    dateCreated: {type: Date, default: Date.now},
    dateLastModified: {type: Date, default: Date.now},
    //status:{type: Number, default: 1, enum: [1,2,3,4]},
    status: {type: String, default: "征集支持中", enum: ['征集支持中', '实现中', '愿望失败', '已实现']},
    type: {type: String, default: "普通", enum: ["普通", "精选"]},    // 精选
    supporters: [
        String // wechat openid
    ],
    supportCount: Number,  // supporters.length
    browseCount: {type: Number, default: 0},
    isValid: {type: Boolean, default: true},

    // date expiry and countdown details
    dateExpired: Date,
    timeLeft: Object
    //daysLeft: Number,
    //hoursLeft: Number,
    //minutesLeft: Number
});
mongoose.model('user_wish', userWishMongoSchema, 'user_wish');